{% extends "mytemplate.html" %}

{% block diffitems %}
<div id="allitems">
    <div id="boughtitems" style="display: {{ buy_display }}">
        <table class="bought-table table table-hover" >
            <caption>买的商品</caption>
            <tbody>
                {% if not orders_buy %}
                <tr><td>暂时还没有买东西哦！</td></tr>
                {% endif %}
                {% for order in orders_buy %}
                <tr class="order-hd">
                    <td colspan="5">
                        <span class="order-num">订单编号：{{order.oid}}</span> 
                        <span class="deal-time">成交时间：{{order.odate}} </span>
                        <span class="shopname"> 卖家: {{order.user.name}}</span>
                        <span class="address">联系方式：{{order.user.addr}} | {{order.user.tel}} </span>
                    </td>
                </tr>
                <tr class="bought-item">
                    <td>{{order.product.name}}</td>
                    <td>{{order.product.descpt}}</td>
                    <td>{{order.price}}</td>
                    <td>{{order.contact}}</td>
                    <td>{%if order.status==0 %} 未支付{%else%}支付完成{%endif%}</td>
                </tr>
                <tr class="sep-row"> <td colspan="5"></td> </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>

    <div id="sellitems" style="display:{{ sell_display }}">
        <table class="bought-table table table-hover table-striped" >
            <caption>卖的商品</caption>
            <tbody>
                {% if not orders_sell %}
                <tr><td>暂时还没有卖东西哦！</td></tr>
                {% endif %}
                {% for order in orders_sell %}
                <tr>
                    <th>商品名称</th>
                    <th>商品描述</th>
                    <th>价格</th>
                    <th>状态</th>
                    {% if order.product.status == 1 %}
                    <th>买家联系方式</th>
                    <th>成交时间</th>
                    {% endif %}
                    {% if order.product.status == 0 %}
                    <th>删除</th>
                    {% endif %}
                </tr>
                <tr class="bought-item">
                    <td>{{order.product.name}}</td>
                    <td>{{order.product.descpt}}</td>
                    <td>{{order.product.price}}</td>
                    <td>{% if order.product.status == 0%}待售{% elif order.status == 0%} 等待买家付款 {% else %}已售{% endif %}</td>
                    {% if order.product.status == 1 %}
                    <td>{{order.contact}}</td>
                    <td>{{order.odate}}</td>
                    {% endif %}
                    
                    {% if order.product.status == 0 %}
                    <td><a href="/item/delete?pid={{order.product.pid}}">X</a></td>
                    {% endif %}
                </tr>
                <tr class="sep-row"> <td colspan="10"></td> </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div> 
{% endblock %}
